<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>论坛首页</title>
<!-- Bootstrap -->
<link href="${ctx }/bt/css/bootstrap.css" rel="stylesheet">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="${ctx }/bt/js/jquery-1.11.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="${ctx }/bt/js/bootstrap.min.js"></script>

<script type="text/javascript">
    function changePage(ele){
        $(ele).parent().siblings("li").removeClass("active");
        $(ele).parent().addClass("active");
        $("#gotoPage").val($.trim($(ele).text()));
        $("#gotoPageForm").submit();
    }

    $(function(){
        var currentPage = ${requestScope.gotoPage};
        $("#pageList li").each(function(){
            if($(this).text()==currentPage){
                $(this).addClass("active");
                return false;
            }
        })
    })

</script>
<style type="text/css">
    /* body{padding-top: 50px;position: relative;} */
    .label-a1 {
        background-color: #A0E400;
    }
</style>
</head>
<body>
<jsp:include page="/common/_head.jsp"></jsp:include>
<!-- container-fluid -->
<div class="container">
    <div class="row">
        <!-- 主页面-->
        <div class="col-md-8 col-sm-10  ">
            <div class="panel panel-default">
                <div class="panel-heading">帖子列表
                    <div class="pull-right">
                        <a class="btn btn-success btn-xs" title="最新帖子">最新</a>
                        <a class="btn btn-warning btn-xs" title="最热帖子">最热</a>
                        <a class="btn btn-info btn-xs" title="最新回复">新回</a>
                        <a class="btn btn-danger btn-xs" title="查看全部精华贴">精</a>
                        <a class="btn btn-default btn-xs" title="过滤公告置顶帖">滤</a>
                    </div>
                </div>

                <ul class="list-group">
                    <c:forEach items="${pageInfo.list }" var="topic">
                        <li class="list-group-item">
                            <div class="media">
                                <div class="media-left">
                                    <a href="${ctx }/user/info?userid=${topic.uid}">
                                        <img class="media-object" src="${ctx }${topic.head_img_address}" alt="...">
                                    </a>

                                </div>
                                <div class="media-body">
                                    <h5 class="media-heading">
                                        <a href="${ctx }/topic/detail?topicId=${topic.id}">${topic.title }</a>
                                    </h5>
                                    <!-- <small class="label  label-primary">顶</small>
                                    <small class="label  label-danger">精</small>
                                    <small class="label  label-default">锁</small>
                                    <small class="label  label-success">官</small> -->
                                    <small class="label label-a1">订</small>
                                    <p  class="help-block">
                                        <a href="${ctx }/user/info?userid=${topic.uid}">
                                            <u>${topic.username }</u>
                                        </a> 发表于<code>${topic.publish_date }</code>
                                        最后回复:<code>goulin</code>
                                        回复数:<code >12</code>

                                    </p>

                                    <!-- <div class="help-block"></div> -->
                                </div>
                            </div>
                            <div class="clearfix"></div>
                        </li>
                    </c:forEach>
                    <c:if test="${ empty pageInfo.list  }">
                        <li class="list-group-item">
                            <div class="col-md-12">竟然没有一个帖子</div>
                            <div class="clearfix"></div>
                        </li>
                    </c:if>
                </ul>
            </div>

            <!-- 分页 ,最优是6个 -->
            <div class="text-center" style="margin-top: -12px;">
                <ul class="pagination" id="pageList">
                    <li class=""><a href="javascript:void(0);" aria-label="Previous">«</a></li>
                    <c:forEach begin="1" end="${pageInfo.totalPage }" varStatus="state">
                        <li class=""><a href="javascript:void(0);" onclick="changePage(this)">${state.index}</a></li>
                    </c:forEach>
                    <li class=""><a href="javascript:void(0);" aria-label="Previous">»</a></li>
                </ul>
            </div>
            <form action="${ctx }/admin" method="post" id="gotoPageForm">
                <input type="hidden" id="gotoPage" name="currentPage" >
            </form>
        </div>
        <!-- user 列 --->
        <div class="col-md-3 col-sm-8 col-xs-8">
            <!-- 登陆用户信息-->
            <div class="panel panel-default">
                <c:if test="${ empty user  }">
                    <div class="panel-heading">BBS</div>
                    <div class="panel-body text-center">
                        <a class="btn btn-success btn-block" href="${ctx }/register">现在注册</a>
                        <div class="help-block"></div>
                        如果已经注册请<a href="${ctx }/login">登陆</a>
                    </div>
                </c:if>
                <c:if test="${ not empty user  }">
                    <div class="panel-heading">欢迎登陆BBS</div>
                    <div class="panel-body">
                        <div class="media">
                            <div class="media-left">
                                <a href="${ctx }/user/info?userId=${user.id}">
                                    <img class="media-object" src="${ctx }${user.head_img_address}" alt="${user.username }">
                                </a>

                            </div>
                            <div class="media-body">
                                <h4 class="media-heading">
                                    <a href="${ctx }/user/info?userId=${user.id}">${user.username }</a>
                                </h4>
                                <h5>经验值: 0</h5>
                                <h5>用户组:
                                    ${userGroup.name }
                                </h5>
                                <a class="btn btn-info btn-xs ">站内信 <small class="badge ">0</small></a>
                                <%-- <a class="btn btn-info btn-xs " href="${ctx }/logout">退出</a> --%>
                                <a class="btn btn-warning btn-xs " href="${ctx }/topic/send">发帖</a>
                            </div>
                        </div>
                        <div class="clearfix block"></div>
                    </div>
                </c:if>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">分栏列表</div>
                <div class="panel-body">
                    <dl>
                        <dt>热门话题</dt>
                        <dd style="margin-bottom:4px;">
                            <span class="text-warning">社会热门</span>
                            <small class="col-md-offset-1">帖子总数:22</small>
                            <small class="">版主:Admin</small>
                        </dd>
                        <dd style="margin-bottom:4px;">
                            <span class="text-warning">工作热门</span>
                            <small class="col-md-offset-1">帖子总数:22</small>
                            <small class="">版主:sSOID</small>
                        </dd>
                        <dd style="margin-bottom:4px;">
                            <span class="text-warning">工作热门</span>
                            <small class="col-md-offset-1">帖子总数:22</small>
                            <small class="">版主:Admin</small>
                        </dd>
                    </dl>
                    <dl>
                        <mark class="text-warning">工作热门</mark>
                        <small class="col-md-offset-1">帖子总数:22</small>
                        <small class="">版主:Admin</small>
                    </dl>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">活跃用户</div>
                <div class="panel-body">
                    <p></p>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">热门标签</div>
                <div class="panel-body">
                    <p></p>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="/common/_footer.jsp"></jsp:include>
</body>
</html>
